<template>
  <div class="order-info">
    <div class="header-container">
      <div class="header-title">
        <div>订单编号: {{ dataInfo.orderCode ? dataInfo.orderCode : '-' }}</div>
        <div v-if="keyDetailPersonnel" class="importantBtn">重点人员</div>
      </div>
      <div style="display: flex;justify-content: space-between;width: 94%;">
        <div class="header-container-left">
          <div class="header-alone">
            <el-tooltip
                class="box-item"
                effect="dark"
                :content="dataInfo.orderTime"
                placement="top"
            >
              <div>订单时间：{{ dataInfo.orderTime }}</div>
            </el-tooltip>
            <el-tooltip
                class="box-item"
                effect="dark"
                :content="dataInfo.orderHarverName + '-' + dataInfo.orderBuyerTel"
                placement="top"
            >
<!--              <div>收货人信息：{{ dataInfo.orderHarverName + '-' + dataInfo.orderBuyerTel }}</div>-->
              <div>收货人信息：{{ getOrderHarverNameAndTel(dataInfo) }}</div>
            </el-tooltip>
          </div>
          <div class="header-alone">
            <el-tooltip
                class="box-item"
                effect="dark"
                :content="dataInfo.orderBuyerName"
                placement="top"
            >
              <div>买家信息：{{ dataInfo.orderBuyerName }}</div>
            </el-tooltip>
            <el-tooltip
                class="box-item"
                effect="dark"
                :content="dataInfo.orderHarverAddress"
                placement="top"
            >
              <div style="height: 17px;">收货地址：{{ dataInfo.orderHarverAddress }}</div>
            </el-tooltip>
          </div>
          <div class="header-alone">
            <el-tooltip
                class="box-item"
                effect="dark"
                :content="dataInfo.orderBuyerIndo"
                placement="top"
            >
              <div>身份证：{{ dataInfo.orderBuyerIndo }}</div>
            </el-tooltip>
            <el-tooltip
                class="box-item"
                effect="dark"
                :content="dataInfo.orderGoods"
                placement="top"
            >
              <div>购买物品：{{ dataInfo.orderGoods }}</div>
            </el-tooltip>
          </div>
        </div>
        <div class="header-Button">{{ dataInfo.orderStatusName }}</div>
      </div>
    </div>

    <div class="middle-top">
      <div class="middle-content">
        <div class="middle-title">
          <img src="@/assets/images/title-icon.png" alt=""/>
          协同订单
        </div>
        <div style="margin: 5px 0 0 4px">
          <el-icon :size="18"><Warning /></el-icon>
        </div>
        <div class="middleTips">
          收货地址所在区县、收货人手机号一致的订单，选择可作为协同订单联查处置！
        </div>
      </div>
    </div>
    <div class="info" v-if="orderData.length > 0">
      <!-- 表格数据 -->
      <el-table
          :data="orderData"
          border
          height="200px"
          style="overflow: hidden;overflow-y: scroll;"
          :header-cell-style="{ 'text-align': 'center' }"
      >
        <el-table-column
            label="订单编号"
            prop="orderCode"
            :show-overflow-tooltip="true"
            width="170px"
        >
        </el-table-column>
        <el-table-column
            label="订单时间"
            prop="orderTime"
            :show-overflow-tooltip="true"
            width="170px"
        >
        </el-table-column>
        <el-table-column
            label="买家姓名"
            prop="orderBuyerName"
            :show-overflow-tooltip="true" width="100px"
            align="center"
        >
        </el-table-column>
        <el-table-column
            label="联系电话"
            prop="orderBuyerTel"
            :show-overflow-tooltip="true"
            width="130px"
            align="center"
        >
        </el-table-column>
        <el-table-column
            label="收货人姓名"
            prop="orderHarverName"
            :show-overflow-tooltip="true"
            width="130"
            align="center"
        >
        </el-table-column>
        <el-table-column
            label="收货人手机号"
            prop="orderHarverTel"
            :show-overflow-tooltip="true"
            width="130"
            align="center"
        >
        </el-table-column>
        <el-table-column
            label="购买物品"
            prop="orderGoods"
            :show-overflow-tooltip="true"
            min-width="130"
            align="center"
        >
        </el-table-column>
        <el-table-column
            label="收货地址"
            prop="orderHarverAddress"
            :show-overflow-tooltip="true"
            min-width="180"
            align="center"
        >
        </el-table-column>
        <el-table-column
            label="操作"
            :show-overflow-tooltip="true"
            min-width="180"
        >
          <template #default="{ row, $index }">
            <div class="table-operate" @click="handleOperate(row, $index)">
              <el-switch v-model="row.changeOpen"/>
              <span class="detail">{{ row.changeOpen ? '已选择' : '未选择' }}</span>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div v-else
         style="display: flex;align-items: center;justify-content: center;height: 100px;color: grey;font-size: 14px;">
      暂无数据
    </div>
    <el-divider/>
    <div class="order-task-radio">
      <el-radio-group v-model="orderForm.isVaild"
                      @change="orderForm.isVaild === 1 ? isShowBtn = true : isShowBtn = false">
        <el-radio :label="1">有效信息</el-radio>
        <el-radio :label="0">无效信息</el-radio>
      </el-radio-group>
    </div>
    <el-form
        :model="orderForm"
        ref="orderFormRef"
        :rules="queryRules"
        label-width="130px"
    >
      <div class="middle-top" v-if="isShowBtn">
        <div class="middle-title">
          <img src="@/assets/images/title-icon.png" alt=""/>
          被排查人员
        </div>
      </div>
      <div v-if="isShowBtn">
        <el-row>
          <el-col :span="12">
            <el-form-item
                label="被排查人姓名："
                :prop="`validUserInfo.orderStrikeUserName`"
                label-width="130"
            >
              <el-input
                  v-model="orderForm.validUserInfo.orderStrikeUserName"
                  placeholder="请输入被排查人姓名"
                  clearable
                  maxlength="20"
                  class="search-input"
                  show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
                label="现居住地址："
                :prop="`validUserInfo.orderStrikeUserAddress`"
                label-width="130"
            >
              <el-input
                  v-model="orderForm.validUserInfo.orderStrikeUserAddress"
                  placeholder="请输入现居住地址"
                  clearable
                  class="search-input"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item
                label="工作单位："
                :prop="`validUserInfo.orderStrikeUserWork`"
                label-width="130"
            >
              <el-input
                  v-model="orderForm.validUserInfo.orderStrikeUserWork"
                  placeholder="请输入工作单位"
                  clearable
                  maxlength="50"
                  class="search-input"
                  show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
                label="工作职业："
                :prop="`validUserInfo.orderStrikeUserOccupation`"
                label-width="130"
            >
              <el-input
                  v-model="orderForm.validUserInfo.orderStrikeUserOccupation"
                  placeholder="请输入工作职业"
                  clearable
                  maxlength="20"
                  class="search-input"
                  show-word-limit
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="keyPersonnel ? 10 : 12">
            <el-form-item
                label="身份号码："
                :prop="`validUserInfo.orderStrikeUserIndo`"
                label-width="130"
            >
              <el-input
                  v-model="orderForm.validUserInfo.orderStrikeUserIndo"
                  placeholder="请输入身份号码"
                  clearable
                  class="search-input"
                  maxlength="18"
                  @change="keyPersonnelChange(orderForm.validUserInfo.orderStrikeUserIndo, 'check')"
              />
            </el-form-item>
          </el-col>
          <el-col v-if="keyPersonnel" :span="2">
            <div class="importantBtn2">重点人员</div>
          </el-col>
          <el-col :span="12">
            <el-form-item
                label="联系电话："
                :prop="`validUserInfo.orderStrikeUserTel`"
                label-width="130"
            >
              <el-input
                  v-model="orderForm.validUserInfo.orderStrikeUserTel"
                  placeholder="请输入联系电话"
                  clearable
                  class="search-input"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="middle-top" v-if="isShowBtn">
        <div class="middle-title">
          <img src="@/assets/images/title-icon.png" alt=""/>
          无人机
        </div>
      </div>
      <div class="UAV-container" v-if="isShowBtn">
        <div class="UAV-container-left">当前持有{{ orderForm.validDroneInfo.length }}架无人机</div>
        <div class="UAV-container-right">
          <el-button type="primary" @click="addTable">
            <el-icon>
              <Plus/>
            </el-icon>
          </el-button>
        </div>
      </div>
      <!-- 表格数据 -->
      <el-table
          v-if="isShowBtn"
          :data="orderForm.validDroneInfo"
          border
          height="30vh"
          :header-cell-style="{ 'text-align': 'center' }"
      >
        <el-table-column
            label="无人机品牌"
            prop="droneBrand"
            :show-overflow-tooltip="true"
        >
          <template #header>
            <span class="verify-icon">无人机品牌</span>
          </template>
          <template #default="{ row, $index }">
            <el-form-item
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="'validDroneInfo.' + $index + '.droneBrand'"
                :rules="rules.droneBrand"
            >
              <el-input
                  v-model="row.droneBrand"
                  clearable
                  size="mini"
                  placeholder="请填写"
                  maxlength="10"
              />
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column
            label="无人机型号"
            prop="droneModel"
            :show-overflow-tooltip="true"
        >
          <template #header>
            <span class="verify-icon">无人机型号</span>
          </template>
          <template #default="{ row, $index }">
            <el-form-item
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="'validDroneInfo.' + $index + '.droneModel'"
                :rules="rules.droneModel"
            >
              <el-input
                  v-model="row.droneModel"
                  clearable
                  size="mini"
                  placeholder="请填写"
              />
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column
            label="无人机识别码"
            prop="droneCode"
            :show-overflow-tooltip="true"
        >
          <template #header>
            <span class="verify-icon">无人机识别码</span>
          </template>
          <template #default="{ row, $index }">
            <el-form-item
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="
                'validDroneInfo.' + $index + '.droneCode'
              "
                :rules="rules.droneCode"
            >
              <el-input
                  v-model="row.droneCode"
                  @input="inputNoZW($index)"
                  clearable
                  size="mini"
                  placeholder="请填写"
                  maxlength="30"
              />
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column
            label="本人/单位使用"
            prop="droneUse"
            :show-overflow-tooltip="true"
            width="200px"
        >
          <template #header>
            <span class="verify-icon">本人/单位使用</span>
          </template>
          <template #default="{ row, $index }">
            <el-form-item
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="'validDroneInfo.' + $index + '.droneUse'"
                :rules="rules.droneUse"
            >
              <el-select
                  v-model="row.droneUse"
                  placeholder="请选择"
                  clearable
                  style="width: 100%"
              >
                <el-option
                    v-for="dict in useType"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column
            label="用途"
            prop="dronePurpose"
            :show-overflow-tooltip="true"
            width="180"
        >
          <template #header>
            <span class="verify-icon">用途</span>
          </template>
          <template #default="{ row, $index }">
            <el-form-item
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="'validDroneInfo.' + $index + '.dronePurpose'"
                :rules="rules.dronePurpose"
            >
              <el-input
                  v-model="row.dronePurpose"
                  clearable
                  size="mini"
                  maxlength="30"
                  placeholder="请填写"
              />
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column
            label="备注"
            prop="droneRemark"
            :show-overflow-tooltip="true"
            width="180"
        >
          <template #default="{ row }">
            <el-form-item
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="'validDroneInfo.' + $index + '.droneRemark'"
            >
              <el-input
                  v-model="row.droneRemark"
                  clearable
                  size="mini"
                  maxlength="30"
                  placeholder="请填写"
              />
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column
            label="操作"
            :show-overflow-tooltip="true"
            width="60px"
        >
          <template #default="{ $index }">
            <div class="table-operate">
              <el-icon
                  title="删除"
                  color="#E33838"
                  class="table-icon"
                  :size="20"
                  @click="handleDelete($index)"
              >
                <Delete/>
              </el-icon>
            </div>
          </template>
        </el-table-column>
      </el-table>

      <div class="middle-top">
        <div class="middle-title">
          <img src="@/assets/images/title-icon.png" alt=""/>
          核查反馈
        </div>
      </div>
      <div v-if="isShowBtn">
        <el-row>
          <el-col :span="12">
            <el-form-item
                class="orderStrikeInfoClass"
                label="常住地派出所："
                :prop="`orderStrikeInfo.changPoliceId`"
                label-width="130"
            >
              <el-select class="search-input" v-model="orderForm.orderStrikeInfo.changPoliceId"
                         placeholder="请输入常住地派出所">
                <el-option
                    v-for="(column, index) in residentPolice"
                    :key="index"
                    :label="column.deptName"
                    :value="column.deptId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="display: flex">
            <el-form-item
                label="户籍地派出所："
                prop="orderStrikeInfo.isCensu"
                label-width="130"
                style="width: 300px;"
            >
              <el-select
                  v-model="orderForm.orderStrikeInfo.isCensu"
                  placeholder="请选择是否哈尔滨"
                  clearable
                  style="width: 100%"
                  @change="handleWhetherChange"
              >
                <el-option
                    v-for="dict in whetherHarbinOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>

            <el-form-item
                label=""
                :prop="`orderStrikeInfo.censusPoliceId`"
                label-width="10"
                style="width: 400px;"
                v-if="orderForm.orderStrikeInfo.isCensu === 1"
            >
              <el-select
                  v-model="orderForm.orderStrikeInfo.censusPoliceId"
                  placeholder="请选择户籍地派出所"
                  clearable
                  style="width: 100%;"
              >
                <el-option
                    v-for="dict in policeOptions"
                    :key="dict.deptId"
                    :label="dict.deptName"
                    :value="dict.deptId"
                />
              </el-select>
            </el-form-item>

            <el-form-item
                label=""
                prop="orderStrikeInfo.censusPoliceName"
                label-width="10"
                style="width: 400px"
                v-else
            >
              <el-input
                  v-model="orderForm.orderStrikeInfo.censusPoliceName"
                  placeholder="请输入户籍地派出所"
                  clearable
                  maxlength="20"
                  class="search-input"
              />
            </el-form-item>

          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item
                label="宣传禁飞政策："
                :prop="`orderStrikeInfo.xjFlag`"
                label-width="130"
            >
              <div class="mb-2 flex items-center text-sm">
                <el-radio-group v-model="orderForm.orderStrikeInfo.xjFlag">
                  <el-radio
                      :label="item.dictValue"
                      size="large"
                      v-for="item in xjFlagList">
                    {{ item.dictLabel }}
                  </el-radio>
                </el-radio-group>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-row>
        <el-col :span="24">
          <el-form-item
              label="情况备注："
              v-if="orderForm.isVaild == 1"
              label-width="130"
          >
            <el-input
                v-model="orderForm.orderStrikeInfo.remark"
                maxlength="500"
                style="width: 100%;"
                placeholder="请输入情况备注"
                show-word-limit
                type="textarea"
            />
          </el-form-item>
          <el-form-item
              v-else
              label="情况备注："
              :prop="'orderStrikeInfo.remark'"
              label-width="130"
          >
            <el-input
                v-model="orderForm.orderStrikeInfo.remark"
                maxlength="500"
                style="width: 100%;"
                placeholder="请输入情况备注"
                show-word-limit
                type="textarea"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script setup>
import {ref, onMounted} from "vue";
import {orderList, deptList, insertAdd, getDeptPolice, getKeynote, exportgk} from "@/api/orderVerification/order"
import {getDicts} from "@/api/system/dict/data";
import {ElMessage, ElMessageBox} from "element-plus";
import {editPeopleApi, getPoliceSonListApi} from "@/api/erp/unit";

// const data = ref({
//   time: '2023-12-12 12:09',
//   info: '张三 - 134554481466',
//   IDcard: '330110199909092929',
//   person: '张三 - 134554481466',
//   address: '黑龙江省哈尔滨市道里区红星街9',
//   goods: '大疆无人机Mini 3',
// })
const policeOptions = ref([]);
const radio1 = ref('1')
const orderData = ref([]);
const orderForm = ref({
  orderId: "",
  isVaild: 1,
  orderIds: [], //协同订单ID数组
  orderStrikeInfo: {
    changPoliceId: "",
    isCensu: "",
    censusPoliceId: "",
    censusPoliceName: "",
    xjFlag: '',
    remark: ""
  }, //	核查反馈
  validDroneInfo: [], //无人机信息
  validUserInfo: {} //被排查人员信息
});
const orderFormRef = ref();
const queryRules = ref({
  orderStrikeInfo: {
    changPoliceId: [{required: true, message: "请选择常住地派出所", trigger: "blur"}],
    isCensu: [{required: true, message: "请选择是否哈尔滨", trigger: "blur"}],
    censusPoliceId: [{required: true, message: "请输入户籍地派出所", trigger: "blur"}],
    censusPoliceName: [{required: true, message: "请输入户籍地派出所", trigger: "blur"}],
    xjFlag: [{required: true, message: "请选择宣传禁飞政策", trigger: "blur"}],
    remark: [
      {required: true, message: "请输入情况备注", trigger: "blur"},
    ],
  },
  validUserInfo: {
    orderStrikeUserName: [{required: true, message: "请输入被排查人姓名", trigger: "blur"}],
    orderStrikeUserAddress: [{required: true, message: "请输入现居住地址", trigger: "blur"}],
    orderStrikeUserWork: [{required: true, message: "请输入工作单位", trigger: "blur"}],
    orderStrikeUserOccupation: [{required: true, message: "请输入工作职业", trigger: "blur"}],
    orderStrikeUserIndo: [{required: true, message: "请输入身份号码", trigger: "blur"}],
    orderStrikeUserTel: [
      {required: true, message: "请输入联系电话", trigger: "blur"},
      {
        pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
        message: "请输入正确格式的手机号码",
        trigger: "blur",
      }
    ],
  }
})
const rules = ref({
  droneBrand: [
    {required: true, message: "请输入无人机品牌", trigger: "blur"},
  ],
  droneModel: [{required: true, message: "请输入无人机型号", trigger: "blur"}],
  dronePurpose: [{required: true, message: "请输入用途", trigger: "blur"}],
  droneCode: [
    {required: true, message: "请输入无人机识别码", trigger: "blur"},
  ],
  droneUse: [
    {required: true, message: "请选择本人/单位使用", trigger: "change"},
  ],
});
const dataInfo = ref({});
const useType = ref([
  {
    dictLabel: "本人使用",
    dictValue: 0,
  },
  {
    dictLabel: "单位使用",
    dictValue: 1,
  },
]);
const isShowBtn = ref(true);
const emit = defineEmits(["refreshList", "keyPersonnelFun", "closeTwiceChange"]);

const whetherHarbinOptions = ref([
  {
    dictValue: 1,
    dictLabel: "是",
  },
  {
    dictValue: 0,
    dictLabel: "否",
  },
]);

let statusWhether = 1;
const handleWhetherChange = (value) => {
  console.log(value)
  if (value === 1) {
    statusWhether = 1;
    orderForm.value.censusPoliceName = "";
  } else if (value === 0) {
    statusWhether = 0;
    orderForm.value.censusPoliceId = "";
  } else {
    statusWhether = 1;
    orderForm.value.censusPoliceName = "";
    orderForm.value.censusPoliceId = "";
  }
};


/*
* 添加无人机
* */
let numberCS = 0;
const addTable = () => {
  if (
      (orderForm.value.validDroneInfo.length > 0 &&
          orderForm.value.validDroneInfo[orderForm.value.validDroneInfo.length - 1].droneBrand === "" &&
          numberCS > 0) ||
      (orderForm.value.validDroneInfo.length > 0 &&
          orderForm.value.validDroneInfo[orderForm.value.validDroneInfo.length - 1].droneModel === "" &&
          numberCS > 0) ||
      (orderForm.value.validDroneInfo.length > 0 &&
          orderForm.value.validDroneInfo[orderForm.value.validDroneInfo.length - 1].droneCode === "" &&
          numberCS > 0) ||
      (orderForm.value.validDroneInfo.length > 0 &&
          orderForm.value.validDroneInfo[orderForm.value.validDroneInfo.length - 1].droneUse === "" &&
          numberCS > 0) ||
      (orderForm.value.validDroneInfo.length > 0 &&
          orderForm.value.validDroneInfo[orderForm.value.validDroneInfo.length - 1].dronePurpose === "" &&
          numberCS > 0)
  ) {
    return;
  }
  let info = {
    droneBrand: "",
    droneModel: "",
    droneCode: "",
    droneUse: null,
    dronePurpose: "",
    droneRemark: ""
  };
  orderForm.value.validDroneInfo.push(info);
  numberCS++;
}

/**
 * @description:  获取派出所
 * @param {Number} id
 */
const getpolicestation = () => {
  getPoliceSonListApi().then((res) => {
    console.log("获取派出所");
    console.log(res);
    policeOptions.value = res;
  });
};

/*
* 删除无人机信息
* */
const handleDelete = (tabIndex) => {
  ElMessageBox.confirm("此操作将删除这条数据，是否继续？", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    confirmButtonClass: "confirmBtnClass",
    cancelButtonClass: "cancelBtnClass",
    type: "warning",
  }).then(() => {
    orderForm.value.validDroneInfo.splice(tabIndex, 1);
  })
};

/*
* 获取订单协同数据
* */
const getOrderList = (id) => {
  orderList(id).then((res) => {
    if (res.code === 200) {
      orderData.value = res.data;
    }
  })
}

/*
* 获取常住地派出所下拉数据
* */
const residentPolice = ref([]);
const getDeptList = () => {
  getDeptPolice().then((res) => {
    if (res.code === 200) {
      residentPolice.value = res.data;
    }
  })
}

/*
* 获取宣传禁飞政策字典
* */
let xjFlagList = ref([]);
const getDictsList = () => {
  getDicts('data_strike_type').then((res) => {
    if (res.code === 200) {
      xjFlagList.value = res.data;
      console.log("xjFlagList.value", xjFlagList.value)
    }
  })
}

/*
* 确认提交
* */
const submitForm = async () => {
  await orderFormRef.value.validate(async (valid, fields) => {
    if (valid) {
      if (keyPersonnel.value) {
        emit('keyPersonnelFun', keyPersonnel.value);
      } else {
        ElMessageBox.confirm("确定保存以上数据吗？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          confirmButtonClass: "confirmBtnClass",
          cancelButtonClass: "cancelBtnClass",
        })
            .then(async () => {
              submitFormSure();
            })
            .catch(() => {
            });
      }

    }
  });
}

const inputNoZW = (index) => {
    orderForm.value.validDroneInfo[index].droneCode =  orderForm.value.validDroneInfo[index].droneCode.replace(/[\u4e00-\u9fa5]/g, '');
}

const submitFormSure = (type) => {
  insertAdd(orderForm.value).then((res) => {
    if (res.code === 200) {
      if (orderForm.value.isVaild === 1 && type !== 'next') {
        emit("closeTwiceChange", res.data.screeningPersonnelId);
        if (keyPersonnel.value) {
          ElMessage.success(res.msg);
        }else{
          ElMessage({
            message: '核查反馈已提交成功！',
            type: 'success',
          })
        }
        cancel()
      } else {
        numberCS = 0;
        if (keyPersonnel.value) {
          ElMessage.success(res.msg);
        }else{
          ElMessage({
            message: '核查反馈已提交成功！',
            type: 'success',
          })
        }
        cancel()
        emit("update:checkVisible", false);
        emit("refreshList");
      }
      ;
    } else {
      ElMessage.error(res.msg);
    }
  });
}

/*
* 取消
* */
const cancel = () => {
  numberCS = 0;
  orderData.value = [];
  orderForm.value = {
    orderId: "",
    isVaild: 1,
    orderIds: [], //协同订单ID数组
    orderStrikeInfo: {
      changPoliceId: "",
      censusPoliceId: "",
      xjFlag: '',
      remark: "",
      censusPoliceName: ""
    }, //	核查反馈
    validDroneInfo: [], //无人机信息
    validUserInfo: {} //被排查人员信息
  }
  isShowBtn.value = true;
  keyPersonnel.value = false;
}

/*
* 判断是否为重点人员
* */
const keyPersonnel = ref(false);
const keyDetailPersonnel = ref(false);
const keyPersonnelChange = (val, type) => {
  console.log("身份证号", val)
  if (val) {
    getKeynote({indo: val}).then((res) => {
      if (res.code === 200) {
        switch (type) {
          case 'detail':
            keyDetailPersonnel.value = res.data;
            break;
          case 'check':
            keyPersonnel.value = res.data;
            break;
        }
      }
    })
  }
}

/*
* 协同订单的选择
* */
const handleOperate = (row) => {
  let obj = orderForm.value.orderIds.findIndex((item) => item === row.id);
  if (obj === -1) {
    orderForm.value.orderIds.push(row.id)
  } else {
    orderForm.value.orderIds.splice(obj, 1);
  }
}

/*
* 赋值
* */
const getInfo = (row) => {
  orderForm.value.orderId = row.id;
  dataInfo.value = row;
  getOrderList(dataInfo.value.id);
  keyPersonnelChange(row.orderBuyerIndo, 'detail')
}

const getOrderHarverNameAndTel = (object) => {
  let name = "-";
  let tel = "-";
  console.log(object)
  if (object && !!object.orderHarverName) name = object.orderHarverName;
  if (object && !!object.orderBuyerTel) tel = object.orderBuyerTel;
  return name + '-' + tel;
}

onMounted(() => {
  getDeptList();
  getDictsList();
  getpolicestation();
  keyPersonnel.value = false;
})

defineExpose({
  submitForm,
  cancel,
  submitFormSure,
  getInfo
});

</script>
<style scoped lang="scss">
.order-info {
  padding: 0 20px;
}

.header-container {
  width: 100%;
  height: 125px;
  background-color: #f4fbfe;
  font-size: 14px;
  color: #666666;
  padding: 15px;

  .header-container-left {
    width: 70%;
    display: flex;
    align-content: space-between;
    justify-content: space-between;
  }

  .header-title {
    display: flex;
    align-items: center;
    width: 25%;
    justify-content: space-between;
  }

  .header-alone {
    width: 240px;
    height: 55px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    overflow: hidden;
  }

  .header-Button {
    width: 70px;
    height: 70px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px grey solid;
  }

  .importantBtn {
    width: 95px;
    height: 33px;
    color: #f59d2a;
    background-color: #f6f0e3;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
  }

}

.importantBtn2 {
  width: 92px;
  height: 33px;
  color: #f59d2a;
  background-color: #f6f0e3;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  margin-left: 20px;
}

.middle-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;

  .middle-title {
    font-size: 16px;
  }
  .middle-content{
    display: flex;
    align-items: center;
    .middleTips{
      width: 520px;
      height: 100%;
      background: url(/src/assets/images/leftJian.png);
      padding-left: 22px;
      background-size: 100% 100%;
      display: flex;
      align-items: center;
      margin-left: 10px;
      color: #ffffff;
    }
  }
}

.table-operate {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

.UAV-container {
  display: flex;
  justify-content: space-between;
  margin: 10px 0 20px;

  .UAV-container-left {
    width: 89%;
    height: 50px;
    background-color: #fff0dc;
    color: #ee5705;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
  }

  .UAV-container-right {
    width: 9%;

    :deep(.el-button) {
      width: 100%;
      height: 50px;
    }
  }
}
</style>
<style>
.order-task-radio {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;

  .el-radio-group {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  .el-radio {
    width: 48.5%;
    height: 42px;
    background-color: #f7f7f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
  }

  .is-checked {
    background-color: #e5eeff;
  }

  .el-radio__label, .el-radio__input.is-checked + .el-radio__label {
    font-size: 16px;
  }
}

.orderStrikeInfoClass {
  .el-select {
    width: 100%;
  }
}
</style>

































